@tool

enum StateTypes {
	AtomicState = 1,
	CompoundState = 2,
	ParallelState = 3,
	AnimationPlayerState = 4,
	AnimationTreeState = 5
}
#region 属性
#endregion
#region 字段
#endregion
#region 信号
#endregion

#region 基类方法
#endregion
#region 公共方法
## chart:当前chart
## path:State路径
## active:当前的active
## transition_pending:此State当前是否正在转换
## transition_path：转换的路径
## transition_delay：转换的剩余转换延迟（如果有的话）
## state：State种类
static func make_array(chart:NodePath,path:NodePath,active:bool,transition_pending:bool,transition_path:NodePath,transition_delay:float,state:State) -> Array:
	return [chart,path,active,transition_pending,transition_path,transition_delay,type_for_state(state)]
static func type_for_state(state:State) -> StateTypes:
	if state is State_Compound:
		return StateTypes.CompoundState
	elif state is State_Parallel:
		return StateTypes.ParallelState
	elif state is State_AnimationPlayer:
		return StateTypes.AnimationPlayerState
	# TODO 暂时没有
	#elif state is State_AnimationTree:
		#return StateTypes.AnimationTreeState
	else:
		return StateTypes.AtomicState
static func get_chart(array:Array) -> NodePath:
	return array[0]
static func get_state(array:Array) -> NodePath:
	return array[1]
static func get_active(array:Array) -> bool:
	return array[2]
static func get_transition_pending(array:Array) -> bool:
	return array[3]
static func get_transition_path(array:Array) -> NodePath:
	return array[4]
static func get_transition_delay(array:Array) -> float:
	return array[5]
static func get_state_type(array:Array) -> StateTypes:
	return array[6]
static func get_state_icon(array:Array) -> Texture2D:
	var type = get_state_type(array)
	if type == StateTypes.AtomicState:
		return preload("res://addons/State_Chart/icons/atomic_state.svg")
	elif type == StateTypes.CompoundState:
		return preload("res://addons/State_Chart/icons/compound_state.svg")
	elif type == StateTypes.ParallelState:
		return preload("res://addons/State_Chart/icons/parallel_state.svg")
	elif type == StateTypes.AnimationPlayerState:
		return preload("res://addons/State_Chart/icons/animation_player_state.svg")
	elif type == StateTypes.AnimationTreeState:
		return preload("res://addons/State_Chart/icons/animation_tree_state.svg")
	else:
		return null
static func set_active(array:Array,active:bool):
	array[2] = active
	if not active:
		array[3] = false
		array[4] = null
		array[5] = 0.0
static func set_transition_pending(array:Array,transition:NodePath,pending_time:float):
	array[3] = true
	array[4] = transition
	array[5] = pending_time
#endregion
#region 私有方法
#endregion
#region 生命周期函数
#endregion
